package com.kaishengit.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.TaskTypeDao;
import com.kaishengit.pojo.TaskType;
import com.kaishengit.pojo.User;
@Transactional
public class TaskTypeService {
	private TaskTypeDao taskTypeDao;
	public List<TaskType> findTypeByUser(User user) {
		return taskTypeDao.findAllByProperty("user",user);
		
	}
	public TaskType findById(String leibie) {
		return taskTypeDao.findByUnique("id",leibie);
	}
	public TaskType save(User user, String name) {
		TaskType type = new TaskType();
		type.setColor("#000000");
		type.setUser(user);
		type.setTypeContent(name);
		taskTypeDao.save(type);
		System.out.println(type.getId());
		TaskType type2 = taskTypeDao.findByUnique("id",type.getId());
		type2.setTaskSet(null);
		user.setContactSet(null);
		user.setDealSet(null);
		user.setNoteSet(null);
		user.setTaskTypeSet(null);
		user.setTagSet(null);
		
		return type2;
		
		
	}
	public void setTaskTypeDao(TaskTypeDao taskTypeDao) {
		this.taskTypeDao = taskTypeDao;
	}
	public void del(String id) {
		taskTypeDao.del(id);
		
	}
	public void update(TaskType type2) {
		taskTypeDao.save(type2);
		
	}
	
	
	

}
